home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_A / OPLIB.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  11KB  |  346 lines

  1. /* $Id: oplib.h,v 1.10 1998/12/18 10:02:03 davem Exp $
  2.  * oplib.h:  Describes the interface and available routines in the
  3.  *           Linux Prom library.
  4.  *
  5.  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  6.  * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7.  */
  8.  
  9. #ifndef __SPARC64_OPLIB_H
  10. #define __SPARC64_OPLIB_H
  11.  
  12. #include <asm/openprom.h>
  13.  
  14. /* Enumeration to describe the prom major version we have detected. */
  15. enum prom_major_version {
  16.     PROM_V0,      /* Original sun4c V0 prom */
  17.     PROM_V2,      /* sun4c and early sun4m V2 prom */
  18.     PROM_V3,      /* sun4m and later, up to sun4d/sun4e machines V3 */
  19.     PROM_P1275,   /* IEEE compliant ISA based Sun PROM, only sun4u */
  20.         PROM_AP1000,  /* actually no prom at all */
  21. };
  22.  
  23. extern enum prom_major_version prom_vers;
  24. /* Revision, and firmware revision. */
  25. extern unsigned int prom_rev, prom_prev;
  26.  
  27. /* Root node of the prom device tree, this stays constant after
  28.  * initialization is complete.
  29.  */
  30. extern int prom_root_node;
  31.  
  32. /* PROM stdin and stdout */
  33. extern int prom_stdin, prom_stdout;
  34.  
  35. /* /chosen node of the prom device tree, this stays constant after
  36.  * initialization is complete.
  37.  */
  38. extern int prom_chosen_node;
  39.  
  40. struct linux_mlist_p1275 {
  41.     struct linux_mlist_p1275 *theres_more;
  42.     unsigned long start_adr;
  43.     unsigned long num_bytes;
  44. };
  45.  
  46. struct linux_mem_p1275 {
  47.     struct linux_mlist_p1275 **p1275_totphys;
  48.     struct linux_mlist_p1275 **p1275_prommap;
  49.     struct linux_mlist_p1275 **p1275_available; /* What we can use */
  50. };
  51.  
  52. /* The functions... */
  53.  
  54. /* You must call prom_init() before using any of the library services,
  55.  * preferably as early as possible.  Pass it the romvec pointer.
  56.  */
  57. extern void prom_init(void *cif_handler, void *cif_stack);
  58.  
  59. /* Boot argument acquisition, returns the boot command line string. */
  60. extern char *prom_getbootargs(void);
  61.  
  62. /* Device utilities. */
  63.  
  64. /* Device operations. */
  65.  
  66. /* Open the device described by the passed string.  Note, that the format
  67.  * of the string is different on V0 vs. V2->higher proms.  The caller must
  68.  * know what he/she is doing!  Returns the device descriptor, an int.
  69.  */
  70. extern int prom_devopen(char *device_string);
  71.  
  72. /* Close a previously opened device described by the passed integer
  73.  * descriptor.
  74.  */
  75. extern int prom_devclose(int device_handle);
  76.  
  77. /* Do a seek operation on the device described by the passed integer
  78.  * descriptor.
  79.  */
  80. extern void prom_seek(int device_handle, unsigned int seek_hival,
  81.               unsigned int seek_lowval);
  82.  
  83. /* Machine memory configuration routine. */
  84.  
  85. /* This function returns a V0 format memory descriptor table, it has three
  86.  * entries.  One for the total amount of physical ram on the machine, one
  87.  * for the amount of physical ram available, and one describing the virtual
  88.  * areas which are allocated by the prom.  So, in a sense the physical
  89.  * available is a calculation of the total physical minus the physical mapped
  90.  * by the prom with virtual mappings.
  91.  *
  92.  * These lists are returned pre-sorted, this should make your life easier
  93.  * since the prom itself is way too lazy to do such nice things.
  94.  */
  95. extern struct linux_mem_p1275 *prom_meminfo(void);
  96.  
  97. /* Miscellaneous routines, don't really fit in any category per se. */
  98.  
  99. /* Reboot the machine with the command line passed. */
  100. extern void prom_reboot(char *boot_command);
  101.  
  102. /* Evaluate the forth string passed. */
  103. extern void prom_feval(char *forth_string);
  104.  
  105. /* Enter the prom, with possibility of continuation with the 'go'
  106.  * command in newer proms.
  107.  */
  108. extern void prom_cmdline(void);
  109.  
  110. /* Enter the prom, with no chance of continuation for the stand-alone
  111.  * which calls this.
  112.  */
  113. extern void prom_halt(void) __attribute__ ((noreturn));
  114.  
  115. /* Set the PROM 'sync' callback function to the passed function pointer.
  116.  * When the user gives the 'sync' command at the prom prompt while the
  117.  * kernel is still active, the prom will call this routine.
  118.  *
  119.  */
  120. typedef int (*callback_func_t)(long *cmd);
  121. extern void prom_setcallback(callback_func_t func_ptr);
  122.  
  123. /* Acquire the IDPROM of the root node in the prom device tree.  This
  124.  * gets passed a buffer where you would like it stuffed.  The return value
  125.  * is the format type of this idprom or 0xff on error.
  126.  */
  127. extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
  128.  
  129. /* Get the prom major version. */
  130. extern int prom_version(void);
  131.  
  132. /* Get the prom plugin revision. */
  133. extern int prom_getrev(void);
  134.  
  135. /* Get the prom firmware revision. */
  136. extern int prom_getprev(void);
  137.  
  138. /* Character operations to/from the console.... */
  139.  
  140. /* Non-blocking get character from console. */
  141. extern int prom_nbgetchar(void);
  142.  
  143. /* Non-blocking put character to console. */
  144. extern int prom_nbputchar(char character);
  145.  
  146. /* Blocking get character from console. */
  147. extern char prom_getchar(void);
  148.  
  149. /* Blocking put character to console. */
  150. extern void prom_putchar(char character);
  151.  
  152. /* Prom's internal printf routine, don't use in kernel/boot code. */
  153. void prom_printf(char *fmt, ...);
  154.  
  155. /* Query for input device type */
  156.  
  157. enum prom_input_device {
  158.     PROMDEV_IKBD,            /* input from keyboard */
  159.     PROMDEV_ITTYA,            /* input from ttya */
  160.     PROMDEV_ITTYB,            /* input from ttyb */
  161.     PROMDEV_I_UNK,
  162. };
  163.  
  164. extern enum prom_input_device prom_query_input_device(void);
  165.  
  166. /* Query for output device type */
  167.  
  168. enum prom_output_device {
  169.     PROMDEV_OSCREEN,        /* to screen */
  170.     PROMDEV_OTTYA,            /* to ttya */
  171.     PROMDEV_OTTYB,            /* to ttyb */
  172.     PROMDEV_O_UNK,
  173. };
  174.  
  175. extern enum prom_output_device prom_query_output_device(void);
  176.  
  177. /* Multiprocessor operations... */
  178. #ifdef __SMP__
  179. /* Start the CPU with the given device tree node, context table, and context
  180.  * at the passed program counter.
  181.  */
  182. extern void prom_startcpu(int cpunode, unsigned long pc, unsigned long o0);
  183.  
  184. /* Stop the current CPU. */
  185. extern void prom_stopself(void);
  186.  
  187. /* Idle the current CPU. */
  188. extern void prom_idleself(void);
  189.  
  190. /* Resume the CPU with the passed device tree node. */
  191. extern void prom_resumecpu(int cpunode);
  192. #endif
  193.  
  194. /* Power management interfaces. */
  195.  
  196. /* Put the current CPU to sleep. */
  197. extern void prom_sleepself(void);
  198.  
  199. /* Put the entire system to sleep. */
  200. extern int prom_sleepsystem(void);
  201.  
  202. /* Initiate a wakeup event. */
  203. extern int prom_wakeupsystem(void);
  204.  
  205. /* MMU and memory related OBP interfaces. */
  206.  
  207. /* Get unique string identifying SIMM at given physical address. */
  208. extern int prom_getunumber(unsigned long phys_lo, unsigned long phys_hi,
  209.                char *buf, int buflen);
  210.  
  211. /* Retain physical memory to the caller across soft resets. */
  212. extern unsigned long prom_retain(char *name,
  213.                  unsigned long pa_low, unsigned long pa_high,
  214.                  long size, long align);
  215.  
  216. /* Load explicit I/D TLB entries into the calling processor. */
  217. extern long prom_itlb_load(unsigned long index,
  218.                unsigned long tte_data,
  219.                unsigned long vaddr);
  220.  
  221. extern long prom_dtlb_load(unsigned long index,
  222.                unsigned long tte_data,
  223.                unsigned long vaddr);
  224.  
  225. /* PROM device tree traversal functions... */
  226.  
  227. #ifdef PROMLIB_INTERNAL
  228.  
  229. /* Internal version of prom_getchild. */
  230. extern int __prom_getchild(int parent_node);
  231.  
  232. /* Internal version of prom_getsibling. */
  233. extern int __prom_getsibling(int node);
  234.  
  235. #endif
  236.  
  237. /* Get the child node of the given node, or zero if no child exists. */
  238. extern int prom_getchild(int parent_node);
  239.  
  240. /* Get the next sibling node of the given node, or zero if no further
  241.  * siblings exist.
  242.  */
  243. extern int prom_getsibling(int node);
  244.  
  245. /* Get the length, at the passed node, of the given property type.
  246.  * Returns -1 on error (ie. no such property at this node).
  247.  */
  248. extern int prom_getproplen(int thisnode, char *property);
  249.  
  250. /* Fetch the requested property using the given buffer.  Returns
  251.  * the number of bytes the prom put into your buffer or -1 on error.
  252.  */
  253. extern int prom_getproperty(int thisnode, char *property,
  254.                 char *prop_buffer, int propbuf_size);
  255.  
  256. /* Acquire an integer property. */
  257. extern int prom_getint(int node, char *property);
  258.  
  259. /* Acquire an integer property, with a default value. */
  260. extern int prom_getintdefault(int node, char *property, int defval);
  261.  
  262. /* Acquire a boolean property, 0=FALSE 1=TRUE. */
  263. extern int prom_getbool(int node, char *prop);
  264.  
  265. /* Acquire a string property, null string on error. */
  266. extern void prom_getstring(int node, char *prop, char *buf, int bufsize);
  267.  
  268. /* Does the passed node have the given "name"? YES=1 NO=0 */
  269. extern int prom_nodematch(int thisnode, char *name);
  270.  
  271. /* Puts in buffer a prom name in the form name@x,y or name (x for which_io 
  272.  * and y for first regs phys address
  273.  */
  274. extern int prom_getname(int node, char *buf, int buflen);
  275.  
  276. /* Search all siblings starting at the passed node for "name" matching
  277.  * the given string.  Returns the node on success, zero on failure.
  278.  */
  279. extern int prom_searchsiblings(int node_start, char *name);
  280.  
  281. /* Return the first property type, as a string, for the given node.
  282.  * Returns a null string on error. Buffer should be at least 32B long.
  283.  */
  284. extern char *prom_firstprop(int node, char *buffer);
  285.  
  286. /* Returns the next property after the passed property for the given
  287.  * node.  Returns null string on failure. Buffer should be at least 32B long.
  288.  */
  289. extern char *prom_nextprop(int node, char *prev_property, char *buffer);
  290.  
  291. /* Returns 1 if the specified node has given property. */
  292. extern int prom_node_has_property(int node, char *property);
  293.  
  294. /* Returns phandle of the path specified */
  295. extern int prom_finddevice(char *name);
  296.  
  297. /* Set the indicated property at the given node with the passed value.
  298.  * Returns the number of bytes of your value that the prom took.
  299.  */
  300. extern int prom_setprop(int node, char *prop_name, char *prop_value,
  301.             int value_size);
  302.             
  303. extern int prom_pathtoinode(char *path);
  304. extern int prom_inst2pkg(int);
  305.  
  306. /* Client interface level routines. */
  307. extern void prom_set_trap_table(unsigned long tba);
  308.  
  309. /* Dorking with Bus ranges... */
  310.  
  311. /* Adjust reg values with the passed ranges. */
  312. extern void prom_adjust_regs(struct linux_prom_registers *regp, int nregs,
  313.                  struct linux_prom_ranges *rangep, int nranges);
  314.  
  315. /* Adjust child ranges with the passed parent ranges. */
  316. extern void prom_adjust_ranges(struct linux_prom_ranges *cranges, int ncranges,
  317.                    struct linux_prom_ranges *pranges, int npranges);
  318.  
  319. /* Apply ranges of any prom node (and optionally parent node as well) to registers. */
  320. extern void prom_apply_generic_ranges(int node, int parent, 
  321.                       struct linux_prom_registers *sbusregs, int nregs);
  322.                       
  323. extern long p1275_cmd (char *, long, ...);
  324.                    
  325.  
  326. #if 0
  327. #define P1275_SIZE(x) ((((long)((x) / 32)) << 32) | (x))
  328. #else
  329. #define P1275_SIZE(x) x
  330. #endif
  331.  
  332. /* We support at most 16 input and 1 output argument */
  333. #define P1275_ARG_NUMBER        0
  334. #define P1275_ARG_IN_STRING        1
  335. #define P1275_ARG_OUT_BUF        2
  336. #define P1275_ARG_OUT_32B        3
  337. #define P1275_ARG_IN_FUNCTION        4
  338. #define P1275_ARG_IN_BUF        5
  339.  
  340. #define P1275_IN(x) ((x) & 0xf)
  341. #define P1275_OUT(x) (((x) << 4) & 0xf0)
  342. #define P1275_INOUT(i,o) (P1275_IN(i)|P1275_OUT(o))
  343. #define P1275_ARG(n,x) ((x) << ((n)*3 + 8))
  344.  
  345. #endif /* !(__SPARC64_OPLIB_H) */
  346.